﻿@{
    Layout = null;
}
@model EnterpriseFund.Model.YGZAllowance
           
<!DOCTYPE html>

<html>
<head>
    <title>编辑</title>
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <style>
        input.txt,textarea{ width:90%; border:1px solid #aecaf0;}
        input.txt:focus,textarea:focus{border-color:#6e90be;}
        textarea{ height:50px;}
        input.btn{ width:100px;}
        .readonly{ background:#ccc;}
        /**/.hid{ display:none;}
        th{ text-align:right;}
    </style>
    
    @Html.DevExpress().GetStyleSheets(
        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
    )

    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
    )

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/checkinput.js")" type="text/javascript"></script>

<script type="text/javascript">
    //<![CDATA[
    var callbackInitDate;

    function OnStartCallback(s, e) {
        callbackInitDate = new Date();
    }
    function OnEndCallback(s, e) {
        var currentDate = new Date();
        var time = currentDate - callbackInitDate;
//        document.getElementById("labelTime").innerHTML = "Time to retrieve the last data:";
//        document.getElementById("valueTime").innerHTML = time / 1000 + " sec";
    }
    // ]]>
</script>



<script>

    var rootUrl = '@Url.Content("~/YGZAllowance/")';

    function check() {

        var period = $('#period').val();
        if (isEmpty(period)) {
            alert('请输入编号！');
            return false;
        }
        if (!isNumeric(period)) {
            alert('请正确输入编号！');
            return false;
        }
        if (period * 1 == 0) {
            alert('期号不能为零！');
            return false;
        }
        var nsrbm = $('#nsrbm').val();
        if (isEmpty(nsrbm)) {
            alert('请输入纳税人编码！');
            return false;
        }
        var NSRDZDAH = $('#NSRDZDAH').val();
        if (isEmpty(NSRDZDAH)) {
            alert('该纳税人编码不存在！');
            return false;
        }
        var amount = $('#amount').val();
        if (isEmpty(amount)) {
            alert('请输入金额！');
            return false;
        }
        if (!isFloat(amount)) {
            alert('输入金额不正确！');
            return false;
        }
        if (amount * 1 == 0) {
            alert('输入金额不能为零！');
            return false;
        }
        
        return true;
    }

    function OK() {
        if (check()) {
            var url = '@Url.Content("~/YGZAllowance/save")'; 
            $.post(url, $('#form1').serialize(), function (data) {
                if (data == 'ok') {
                    alert("保存成功！");
                    parent.Cancel();
                    parent.gvEditing.Refresh();
                }
                else if (data == 'err') { alert("保存失败！"); }
                else { alert(data); }
            });
        }
    }

    function checkNSRBM() {
        var bm = $('#nsrbm').val();
        $.get(rootUrl + 'GetNSRMC/' + bm, function (data) {
            if (data) {
                var s = data.split('|');
                $('#nsrmc').val(s[0]);
                nsrmcComboBox.SetText(s[0]);
                $('#NSRDZDAH').val(s[1]);
            }
            else {
                //alert("该纳税人编码不存在！");
                $('#NSRDZDAH').val('');
                $('#nsrmc').val('');
                return false;
            }
            //alert($('#NSRDZDAH').val());
        });
      return true;
  }

  function nsrmcChange() {
      var nsrbm = nsrmcComboBox.GetValue();
      var nsrmc = nsrmcComboBox.GetText();
      if (nsrbm != nsrmc) {
          $("#nsrbm").val(nsrbm);
      }
      else {
          $("#nsrbm").val('');
      }
          checkNSRBM();
  }

</script>

 </head>
<body>
<form action="@Url.Content("~/YGZAllowance/save")" method="post" id="form1" > 
 
<input type="hidden" name="FYGZAllowanceNo" value="@Model.FYGZAllowanceNo" />
<input type="hidden" name="FEntityNo" value="@Model.FEntityNo" />
<input type="hidden" id="NSRDZDAH" name="NSRDZDAH" value="@Model.NSRDZDAH" />
<input type="hidden" name="FInsEmpNo" value="@Model.FInsEmpNo" />
<input type="hidden" name="FInsDeptNo" value="@Model.FInsDeptNo" />
<input type="hidden" name="FInsIP" value="@Model.FInsIP" />
<input type="hidden" name="FInsDate" value="@Model.FInsDate" />

<table cellpadding="2" width="500" border="0" >
    <tr>
        <td width="100" style=" text-align:right">年度:</td>
        <td><input name="FYear" value="@Model.FYear" class="txt readonly" readonly /></td>
    </tr>
    <tr>
        <td width="100" style=" text-align:right">编号:</td>
        <td><input id="period" name="FPeriod" value="@Model.FPeriod" class="txt" maxlength="3"   /></td>
    </tr>
    <tr>
        <td style=" text-align:right">纳税人编码:</td>
        <td>
        <input id="nsrbm" name="nsrbm" value="@ViewBag.nsr.NSRBM" class="txt " onchange="checkNSRBM();" maxlength="10" />
        </td>
    </tr>
    <tr>
        <td style=" text-align:right">纳税人名称:</td>
        <td width="400">
        <input id="nsrmc" name="nsrmc" value="@ViewBag.nsr.NSRMC" class="txt" maxlength="50" />
        <div id="nsrmcComboxDiv">
            @Html.Partial("LargeDataComboBoxPartial")
        </div>

        </td>
    </tr>
    <tr>
        <td style=" text-align:right">补助金额:</td>
        <td>
        <input id="amount" name="FAmount" value="@Model.FAmount" class="txt" maxlength="15" />
        </td>
    </tr>
</table>
<p></p>

</form>
</body>
</html>

<script>
    if (parent.pop) {
        parent.pop.SetHeaderText("");
    }

    var bm = $('#nsrbm').val();
    if (bm != '') {
        $("#nsrbm").attr("readonly", true);
        $("#nsrmc").attr("readonly", true);
        $("#period").attr("readonly", true);
        $("#nsrbm").attr("class", "txt readonly");
        $("#nsrmc").attr("class", "txt readonly");
        $("#period").attr("class", "txt readonly");
        $('#nsrmcComboxDiv').hide();
        if (parent.pop) {
            parent.pop.SetHeaderText("营改增补助信息编辑");
        }
    }
    else { 
        $("#period").val("");
        $('#nsrmc').hide();
        if (parent.pop) {
            parent.pop.SetHeaderText("营改增补助信息录入");
        }
    }
</script>